package com.fp.voiceshoper;

import com.fp.fpShoper.R;
import com.fp.voiceshoper.adapters.MenuArrayAdapter;
import com.fp.voiceshoper.interfaces.MenuActionListener;

import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MenuFragment extends ListFragment {

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		String[] mystr=getResources().getStringArray(R.array.menu_items);
//				new String[] { " New", " Save as", " Clear", " Delete", " Alarm"," Send"," Settings", " Exit"};
		int[] drawable=new int[]{R.drawable.icon_newtab,R.drawable.icon_save_floppy,R.drawable.icon_eraser,R.drawable.icon_trash,
				R.drawable.icon_alarm,R.drawable.icon_share,R.drawable.icon_settingsandroid,R.drawable.icon_exit};
		setListAdapter(new MenuArrayAdapter(getActivity(), mystr, drawable));
		getListView().setCacheColorHint(0);
	}
	
	public static void setListener(MenuActionListener l){
		mActionListener=l;
	}
	
	private static MenuActionListener mActionListener;

	@Override
	public void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		((MenuActivity)getActivity()).getSlideoutHelper().close();
		mActionListener.onMenuItemSelect((int)id);
	}

	
}
